import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/net/post_request.dart';
import 'package:ls_work/net/response/department_list_data.dart';
import 'package:ls_work/net/response/response_data.dart';

class DepartmentListViewModel extends BaseListViewModel<DepartmentListData>{
  DepartmentListViewModel(BuildContext context) : super(context);

  @override
  Future<List<DepartmentListData>> requestListData() async {
    var json = await PostRequest.departmentList();
    var bean = ResponseBean.fromJson(json);
    if("0"==bean.code){
      var data = (bean.data as List).map((e) => DepartmentListData.fromJson(e)).toList();
      return data;
    }else{
     throw bean.msg??"";
    }
  }

  @override
  void onCreated() {
    super.onCreated();
    requestRefresh();
  }

}